local dsp = require "luci.dispatcher"
require("luci.http")

m = Map("hsion_mLink",
	translate("MultiLink"))

s = m:section(TypedSection, "general", translate("General"))
s.anonymous = true
s.addremove = false

o = s:option(Flag, "enabled", translate("Set Enabled"))
o.rmempty = false
o.default = false

s = m:section(TypedSection, "interface", translate("Interface"))
s.anonymous = true
s.addremove = true
s.template = "cbi/tblsection"

--interface
o = s:option(Value, "net", translate("Network"))
o.template = "cbi/network_netlist"
o.rmempty = false
o.width = "8%"

--track_ip
o = s:option(DynamicList , "track_ip", translate("Track IP"))
o.datatype = "ip4addr"
o.rmempty = false
o.width = "15%"

--weight
o = s:option(Value, "weight", translate("Weight"), translate("Bandwidth"))
o.datatype = "uinteger"
o.rmempty = false

--count
o = s:option(Value, "count", translate("Ping Count"))
o.datatype = "uinteger"
o.rmempty = false
o.default = 1

--up
o = s:option(Value, "up", translate("Ping Up"))
o.rmempty = false
o.default = 3

--down
o = s:option(Value, "down", translate("Ping Down"))
o.rmempty = false
o.default = 3

--ping timeout
o = s:option(Value, "timeout", translate("Ping Timeout"), translate("Seconds"))
o.rmempty = false
o.datatype = "uinteger"

--ping timeout
o = s:option(Value, "interval", translate("Ping Interval"), translate("Seconds"))
o.rmempty = false
o.datatype = "uinteger"

local apply = luci.http.formvalue("cbi.apply")
if apply then
    luci.sys.exec("killall -9 hsion_mLink")
	luci.sys.exec("/etc/init.d/hsion_mLink start > /dev/null 2>&1 &")
end

return m
